import { info, getmineInfo } from '@/api/user';

const state = {
    userInfo: {
    },
    mineInfo: {
    }
};

const mutations = {
    SET_USER_INFO: (state, userInfo) => {
        state.userInfo = userInfo;
    },
    SET_MINE_INFO: (state, mineInfo) => {
        state.mineInfo = mineInfo;
    }
};
const actions = {
    async getMineInfo({ commit }, param) {
        const MineInfoResponse = await getmineInfo(param);
        const mineInfo = MineInfoResponse.data.data;
        console.log('触发钱包更新');
        commit('SET_MINE_INFO', mineInfo);
        return mineInfo; // 如果需要在外部访问返回值，可以返回 mineInfo 或者根据需求返回其他内容
    },
    async getInfo({ commit }) {
        const infoResponse = await info();
        const userInfo = infoResponse.data.data;
        commit('SET_USER_INFO', userInfo);
        return userInfo; // 如果需要在外部访问返回值，可以返回 userInfo 或者根据需求返回其他内容
    },
};
export default {
    namespaced: true,
    state,
    mutations,
    actions
};
